package com.mike.bdb.model;

import java.util.HashMap;
import java.util.Map;

import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;

@Entity
public class Alliance {
	
	@PrimaryKey(sequence="alliance_id")
	private long id;
	
	private String name;
	
	private Map<Integer, Person> members = new HashMap<Integer, Person>();

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Person removeMember(Person person) {
		if(null == person) return null;
		return members.remove(person.getId());
	}
	
	public Person addMember(Person person) {
		if(null == person) return null;
		return members.put(person.getId(), person);
	}
	
	public boolean isMember(Person person) {
		return members.containsKey(person.getId());
	}
}
